<?php
include_once dirname(__FILE__).'/Month.class.php';

class Year {
	private $_changed = true;
	
	private $_year;
	private $_year_array;
	
	function __construct($year) {
		$this->setYear($year);
	}
	
	public function setYear($year) {
		$this->_year = ($year == null)?date("Y"):$year;
		$this->_changed = true;
	}
	
	/**
	 * 
	 * @return array
	 */
	public function generate() {
		if ($this->_changed) {
			$this->_year_array = array();
			
			for ($i = 1; $i <= 12; ++$i) {
				$this->_year_array[$i] = new Month($i, $this->_year);
			}
			$this->_changed = false;
		}
		return $this->_year_array;
	}
}
?>